From 640754e98b6a0a59fbfa9f35d03e0f096988a0a2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 16 Dec 2011 18:47:42 +0100 Subject: [PATCH] filechooserentry: Do inline completion only when opening files When saving files, using is required. We don't want the UI randomly changing filenames from below us. https://bugzilla.gnome.org/show_bug.cgi?id=663573 --- gtk/gtkfilechooserentry.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 3010c94218..50d346263d 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -431,6 +431,30 @@ gtk_file_chooser_entry_focus_out_event (GtkWidget *widget, return GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->focus_out_event (widget, event); } +static void +update_inline_completion (GtkFileChooserEntry *chooser_entry) +{ + GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry)); + + if (!chooser_entry->current_folder_loaded) + { + gtk_entry_completion_set_inline_completion (completion, FALSE); + return; + } + + switch (chooser_entry->action) + { + case GTK_FILE_CHOOSER_ACTION_OPEN: + case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: + gtk_entry_completion_set_inline_completion (completion, TRUE); + break; + case GTK_FILE_CHOOSER_ACTION_SAVE: + case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: + gtk_entry_completion_set_inline_completion (completion, FALSE); + break; + } +} + static void discard_completion_store (GtkFileChooserEntry *chooser_entry) { @@ -438,7 +462,7 @@ discard_completion_store (GtkFileChooserEntry *chooser_entry) return; gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL); - gtk_entry_completion_set_inline_completion (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), FALSE); + update_inline_completion (chooser_entry); g_object_unref (chooser_entry->completion_store); chooser_entry->completion_store = NULL; } @@ -529,7 +553,7 @@ finished_loading_cb (GtkFileSystemModel *model, gtk_widget_set_tooltip_text (GTK_WIDGET (chooser_entry), NULL); completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry)); - gtk_entry_completion_set_inline_completion (completion, TRUE); + update_inline_completion (chooser_entry); gtk_entry_completion_complete (completion); gtk_entry_completion_insert_prefix (completion); } @@ -822,6 +846,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry, _gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store), action == GTK_FILE_CHOOSER_ACTION_OPEN || action == GTK_FILE_CHOOSER_ACTION_SAVE); + + update_inline_completion (chooser_entry); } } -- 2.30.2